<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.7
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ###############

class JFX_Module_Imager extends JFX_Module
{
    public $keyname = 'imager';
    public $title = 'Image Management';
    public $imager_config = array();
    public $dependencies = array(
        array(
            'keyname' => 'iusers',
            'version' => '0.1.0'
        )
    );

    public function __construct(){
        parent::__construct();

        $this->loadConfig();
    }





    function LoadConfig(){
        $DB = JFX::registry('db');
        $CONFIG = JFX::registry('config');
        // make sure we have been installed!

        if(!JFX_Module::isInstalled($this->keyname)) return;

        $config = $DB->fetchAll("SELECT * FROM {$CONFIG->dbprefix}imager_config");

        if($config === false) return;
        foreach($config as $k=>$v){
            $this->imager_config[$v['k']] = $v['v'];
        };
    }







    function GetConfig($k){
        if(isset($this->imager_config[$k])) return $this->imager_config[$k];
        else if($this->ThrowConfigExceptions) throw new Exception($this->getTitle().'->GetConfig was asked to find a non-existing key: '.$k);
        else return false;
    }





    public function install(){
        $VIEW = JFX::registry('JFX_View');
        $SMARTY = JFX::registry('Smarty');
        $USER = JFX::registry('JFX_User');
        $CONFIG = JFX::registry('config');
        $DB = JFX::registry('db');
        $dirname = str_replace(DIRECTORY_SEPARATOR, '/', dirname(__FILE__)).'/install';
        include('install/install.php');
    }


    public function uninstall(){
        $VIEW = JFX::registry('JFX_View');
        $SMARTY = JFX::registry('Smarty');
        $USER = JFX::registry('JFX_User');
        $CONFIG = JFX::registry('config');
        $DB = JFX::registry('db');
        $dirname = str_replace(DIRECTORY_SEPARATOR, '/', dirname(__FILE__)).'/install';
        include('install/uninstall.php');
    }





}